//Object.assign
const source1 = {
  a: 123,
  b: 123,
};
const target = {
  a: 456,
  c: 456,
};
const result = Object.assign(target, source1);

console.log(target); //{ a: 123, c: 456, b: 123 }
console.log(result === target); //true

function func(obj) {
  const funcObj = Object.assign({}, obj);
  funcObj.name = "func obj";
  console.log(funcObj);
}
const obj = { name: "global obj" };
func(obj); //{ name: 'func obj' }
console.log(obj); //{ name: 'global obj' }
